package inger.redpac.server.dispatchers;

import java.util.Map;

import com.google.common.collect.Maps;

public class PlainCallableMapDispatcher implements Dispatcher {

	public interface PlainCallable {
		public Object call(Object... params);
	}

	private Map<String, PlainCallable> callableMap;

	public PlainCallableMapDispatcher() {
		super();
		this.callableMap = Maps.newHashMap();
	}

	public PlainCallableMapDispatcher(Map<String, PlainCallable> callableMap) {
		super();
		this.callableMap = callableMap;
	}

	public Map<String, PlainCallable> getCallables() {
		return callableMap;
	}

	@Override
	public Object dispatch(String name, Object params) throws Exception {
		if (this.callableMap.containsKey(name)){
			this.callableMap.get(name);
			// TODO: ...
		} else {
			throw new Exception(String.format("no keyed items -- %s",
					name));
		}
	}

}
